import api from "@/utils/api";
import config from "@/config";

export const globals = {
  /**
   * @description: 城市级联组件请求方法
   * @param {*} resolve 赋值回调
   * @param {*} level 展示的级数
   * @return {*}
   */
  async lazyCityCascader(node = {}, resolve, level = 2) {
    let resCityArr = await api.get(config.CITY_URL, {
      code: node.data?.code || "2147483647",
      type: 1,
      status: 1,
      level: node.data?.level || 1,
    });
    node.level >= level && resCityArr.map((item) => (item.leaf = true));
    resolve(resCityArr);
  },
};
